package com.ttg.web.manage;


import cn.hutool.core.util.EnumUtil;
import com.ttg.common.entities.UserTokenInfo;
import com.ttg.common.enums.ErrorCodeEnums;
import com.ttg.common.exception.BaseException;
import com.ttg.common.vo.OrganCheckSignVo;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;
import java.util.Optional;

/**
 * @author ZQ
 * @version 1.0
 * @Description
 * @date 2020/12/2 16:19
 */
@Slf4j
public class TransFormManager {
    /**
     * 将内部错误码转换成响应错误码枚举
     *
     * @param errcode
     * @return 转换异常, 默认返回系统异常
     */


    /**
     * 转换userInfo信息
     *
     * @param checkSignVo
     * @return
     */
    public static UserTokenInfo transForUserInfo(OrganCheckSignVo checkSignVo) {
        UserTokenInfo user = null;
        if (Objects.nonNull(checkSignVo)) {
            user = new UserTokenInfo();
            user.setShopNo(checkSignVo.getShopNo());
            user.setRequestType(checkSignVo.getRequestType());
            user.setAgentNo(checkSignVo.getAgentNo());
            user.setMctNo(checkSignVo.getMctNo());
            user.setOrgNo(checkSignVo.getOrgNo());
            user.setScrId(checkSignVo.getScrId());
            user.setTokenId(checkSignVo.getTokenId());
            user.setAdmId(checkSignVo.getAdmId());
            user.setLang(checkSignVo.getLang());
            user.setAgentLevel(checkSignVo.getAgentLevel());
            user.setIp(checkSignVo.getIp());
            user.setOrgMaxLevel(checkSignVo.getOrgMaxLevel());

            // 加密类型
            user.setSign_type(checkSignVo.getSign_type());

            // 优惠券客户端登录信息
            user.setVipId(checkSignVo.getVipId());
            user.setVipMobile(checkSignVo.getVipMobile());
            user.setChlId(checkSignVo.getChlId());
            user.setAddress(checkSignVo.getAddress());
            user.setOpenId(checkSignVo.getOpenId());
        }
        return user;
    }
}
